<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class logs extends CI_Controller{
	public function __construct(){
		parent::__construct();
		if(!isset($_SESSION["isadmin"]) || !$_SESSION["isadmin"]){
			header("location:/index.php/login");
		}
	}
	
	public function logslist(){
                $data['logTypeArr'] = array('0'=>'登陆','1'=>'下线','2'=>'加入牌桌','3'=>'离开牌桌','4'=>'发送邮件','5'=>'好友申请','6'=>'同意好友申请','7'=>'充值','8'=>'修改密码');
                $url = "/index.php?c=logs&a=gamelist";
                $userID = isset( $_GET['userID']) && 0 < intval($_GET['userID']) ? intval($_GET['userID']) : '';
                $data['userID'] = $userID;
                if( $uid ){
                    $where  = " WHERE userID = '{$userID}' " ;
                    $url.= "&userID=".$userID;
                }
                $this->config->load('pagination',true);
                $pagesize  = $this->config->item("per_page","pagination");
                $sposition  = isset($_GET['per_page']) && (int)$_GET['per_page'] ? (int)$_GET['per_page'] : 0;
                $where .= " LIMIT $sposition ,$pagesize ";
            
                $sql = " SELECT  * FROM pk_log $where ";
                $this->load->model('LogsModel');
                $data['logList'] = $this->LogsModel->getAll($sql);

                $this->load->library('pagination');
                $config['base_url'] = $url;
                $config['total_rows'] = $this->LogsModel->LogCount($where);
                $this->pagination->initialize($config);
                $data['page'] = $this->pagination->create_links();
                
		$this->load->view("header");
		$this->load->view("logs/logslist",$data);
		$this->load->view("footer");
	}
        
        
        /*用户对局日志*/
        public function gamelist()
        {
            $url = "/index.php?c=logs&a=gamelist";
            
            $uid = isset( $_GET['uid']) && 0 < intval($_GET['uid']) ? intval($_GET['uid']) : 0;
            $data['uid'] = $uid;
            $where = "";
            if( $uid ){
                $where  = " WHERE userID = '{$uid}' " ;
                $url.= "&uid=".$uid;
            }
            
            $userID = isset( $_GET['userID']) && 0 < intval($_GET['userID']) ? intval($_GET['userID']) : '';
            $data['userID'] = $userID;
            if( $uid ){
                $where  = " WHERE userID = '{$userID}' " ;
                $url.= "&userID=".$userID;
            }
            
            $sql = " SELECT  * FROM pk_user_game_log  $where ";
            $this->load->model('LogsModel');
            $data['logList'] = $this->LogsModel->getAll($sql);
            
            $this->load->library('pagination');
            $config['base_url'] = $url;
            $config['total_rows'] = $this->LogsModel->LogsCount($where);
            $this->pagination->initialize($config);
            $data['page'] = $this->pagination->create_links();
            
            $this->load->view("header");
            $this->load->view("logs/gamelist",$data);
            $this->load->view("footer");
	}
	
}